# -*- coding: utf-8 -*-
<%namespace name="tw" module="toscawidgets.mako_util"/>\

{		xtype : 'form',
		id : '${componentId}',
        labelAlign: '${labelAlign}',
        title: '${title}',
        bodyStyle:'${bodyStyle}',
        defaults: ${defaults},
        width: 700,
        height:400,
        border:true,
        frame :  ${str(frame).lower()}, 
        labelWidth: ${labelWidth},
        method: 'POST', 
		url:'${url}',
		buttonAlign: '${buttonAlign.lower()}',
		layout: '${layout}',
		items :[
			<% sep='' %>
			%for item in items:
				${ sep+item.display(value_for(item), **args_for(item)) }
				<% sep=',' %>				
			%endfor		
		] ,
		buttons: [{
            text: 'Save',
            handler: this.SubmitForm	
        },{
            text: 'Cancel'
        }],
        SubmitForm : function() { 
		    if ( this.form.isValid() ) {
		      Ext.MessageBox.alert('Status', 'Passed');
		      this.form.submit({
		        waitMsg:'Authorizing...',
		        reset: false,
		        failure: function(Login, action) {
		          Ext.MessageBox.alert('Error', action.result.message);                        
		        },
		        success: function(Login, action) {
		          location.replace('/');
		        }
		      });
		    } else {
		      Ext.MessageBox.alert('Status', 'Not valid');
		    }
		  },
		  formatBoolean: function(v) {
				switch(v) {
					
					case 1:
					case "1":
					case true:
					case "Yes":
					case "yes":
					case "True":
					case "true":
						return true;
						break;
					default:
						return false;
					
				}
			},
		 store : ${ store.display(value_for(store), **args_for(store)) },
		 afterRender : function(sender){
		 	this.store.on('load', function() {
			});
					 
		 	this.store.load();
		 	// this.on('keypress',this.onKeypress);

		 }
	     			
  }